﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace VPN
{
    public partial class ChangePassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnChange_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                System.Security.Principal.WindowsImpersonationContext wic =
                    ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();
                try
                {
                    VPN.Querier.UserHelper.ChangePassword(User.Identity.Name, txtNew.Text, txtOld.Text);
                    ClientScript.RegisterStartupScript(this.GetType(), "OK", "alert('密码修改完成');", true);
                }
                catch
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Fail", "alert('密码修改失败');", true);
                }
                wic.Undo();
                
            }
        }




    }
}
